/*
 * Created on Mar 27, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package ar.edu.utn.frba.gdaia.src.junittest;


import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import junit.framework.TestCase;
import ar.edu.utn.frba.gdaia.src.action.Command;
import ar.edu.utn.frba.gdaia.src.action.LearnRuleCommand;
import ar.edu.utn.frba.gdaia.src.domain.Canal;
import ar.edu.utn.frba.gdaia.src.domain.Regla;
import ar.edu.utn.frba.gdaia.src.main.Cerebro;
import ar.edu.utn.frba.gdaia.src.main.GDAIA;

/**
 * @author Patricio Prueba el command LearnRule
 */
public class LearnRuleCommandTest extends TestCase {

	public static void main(String[] args) {
		junit.swingui.TestRunner.run(LearnRuleCommandTest.class);
	}

	Cerebro cerebro = null;

	GDAIA gdaia = new GDAIA();

	Map parameters = null;

	/**
	 * Constructor for LearnRuleCommandTest.
	 * 
	 * @param arg0
	 */
	public LearnRuleCommandTest(String arg0) {
		super(arg0);

	}

	/*
	 * @see TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
		cerebro = new GDAIA().generateCerebroFromXML();
		parameters = new HashMap();
		parameters.put(Command.CEREBRO, cerebro);
	}

	/*
	 * @see TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
		gdaia.generateXMLForCerebro(cerebro);
	}

	public final void testExecute() {
		Regla reglaPorAprender = new Regla(-1, null,
				new Date(), cerebro.getSituacionPrevia(), null, cerebro
						.getSituacionActual(), Canal.INT_MAKE_PRESENT_SIT);
		new LearnRuleCommand().execute(parameters);
		boolean ret = cerebro.getReglasExternas().contains(reglaPorAprender);
		assertTrue(ret);
	}

}
